//
//  EightViewController.m
//  DongChiDaChiProject1
//
//  Created by lanou3g on 15/10/27.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "EightViewController.h"
#import "EightFoodwCell.h"
#import "EightFoodManager.h"
#import "ChuanFoodController.h"

@interface EightViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) NSMutableArray *dataArray;
@property (nonatomic, retain) UITableView *tableView;

@end

@implementation EightViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"食客说";
    [self.navigationController.navigationBar setTranslucent:NO];
      [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHue:0.1 saturation:0.3 brightness:1 alpha:1]];
    self.view.backgroundColor = [[UIColor orangeColor]colorWithAlphaComponent:0.2];
    [self addSubViews];
      
}

#pragma mark - 视图将要出现
- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}


// 添加表视图
- (void)addSubViews
{
    self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:(UITableViewStylePlain)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    // 取消下划线
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 70 * kWidthFitParameter)];
    self.tableView.tableFooterView = footView;
    [self.view addSubview:self.tableView];
    
}
// 表格的代理方法
// 返回分区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
    
}
// 分区多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 8;
}
// 设置单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"myCell";
    EightFoodwCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[EightFoodwCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:identifier];
    }

    
    if (indexPath.row == 0) {
        cell.caixiLable.text = @"川菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"chuan1.jpg"];
    }else if (indexPath.row == 1){
         cell.caixiLable.text = @"浙菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"zhecai.jpg"];
    }else if (indexPath.row == 2){
        cell.caixiLable.text = @"闽菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"mincai.jpg"];
    }else if (indexPath.row == 3){
        cell.caixiLable.text = @"湘菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"xi.jpg"];

    }else if (indexPath.row == 4){
        cell.caixiLable.text = @"徽菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"hui.jpg"];
    }else if (indexPath.row == 5){
        cell.caixiLable.text = @"鲁菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"68268985.jpg"];
    }else if (indexPath.row == 6){
        cell.caixiLable.text = @"苏菜";
         cell.imageBackPicture.image = [UIImage imageNamed:@"sucai.jpg"];
    }else {
        cell.caixiLable.text = @"粤菜";
        cell.imageBackPicture.image = [UIImage imageNamed:@"yuecai.jpg"];
    }
    return cell;
}
// 设置单元格行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    return (kScreenHeight / 4 + 50) * kWidthFitParameter;
}
// cell 的点击方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.row == 0) {
        // 跳到川菜的 controller
        ChuanFoodController *chuanCaiVC = [[ChuanFoodController alloc] init];
        [self.navigationController pushViewController:chuanCaiVC animated:YES];
    }else if (indexPath.row == 1){
        ZheFoodController *zheVC = [[ZheFoodController alloc] init];
        [self.navigationController pushViewController:zheVC animated:YES];
        
    }else if (indexPath.row == 2){
        MinFoodController *minVC = [[MinFoodController alloc] init];
        [self.navigationController pushViewController:minVC animated:YES];
    }else if (indexPath.row == 3){
        XiangFoodController *xiangVC = [[XiangFoodController alloc] init];
        [self.navigationController pushViewController:xiangVC animated:YES];
        
    }else if (indexPath.row == 4){
        HuiFoodController *huiVC = [[HuiFoodController alloc] init];
        [self.navigationController pushViewController:huiVC animated:YES];
    }else if (indexPath.row == 5){
        LuFoodController *luVC = [[LuFoodController alloc] init];
        [self.navigationController pushViewController:luVC animated:YES];
    }else if (indexPath.row == 6){
        SuFoodController *suVC = [[SuFoodController alloc] init];
        [self.navigationController pushViewController:suVC animated:YES];
    }else {
        YueFoodController *yueVC = [[YueFoodController alloc] init];
        [self.navigationController pushViewController:yueVC animated:YES];
    }

    
}


//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
//{
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 30 *kWidthFitParameter)];
//    return view;
//}
//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
//{
//    return 30 *kWidthFitParameter;
//}
@end
